package algorithm.markovLink;

public class Utils {
	private Utils() {
	}

	/**
	 * gets index of matrix by char
	 * 
	 * @param c
	 * @return
	 */
	public static int char2Idx(char c) {
		int idx = c - 'a';
		if (idx < 26 && idx >= 0)
			return idx;
		else
			return -1;
	}

	public static char idx2Char(int idx) {
		if (idx < 26 && idx >= 0)
			return (char) (idx + 'a');
		else
			return '\0';
	}

	public static void dispMatrix(int[][] matrix) {
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[i].length; j++) {
				System.out.print(String.format("%5s", matrix[i][j]));
			}
			System.out.println();
		}
	}

}
